<template>
    <div v-for="(article, index) in articles" :key="index">
      {{ article.authorId }}<span>{{ article.createdAt }}</span>
      <h1>{{ article.title }}</h1>
      <p>{{ article.description }}</p>
      <p>查看更多...</p>
      <hr color="#EBEDF0" />
    </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return { articles: [] };
  },
  async created() {
    try {
      const response = await axios.get("/api/articles");
      this.articles = response.data;
    } catch (error) {
      console.error("获取文章数据失败:", error);
    }
  },
};
</script>
